#include "ScnsKeyboardGpio.c.h"

#if defined(SCNS_KEYBOARD_GPIO_ENABLE)&&SCNS_KEYBOARD_GPIO_ENABLE==1

#include "ScnsKey.h"

const ScnsKeyEnum scnsBspKeyboardGpioKeyEnum[SCNS_BSP_KEYBOARD_GPIO_KEY_MAX]={
    SCNS_KEY_S1,
    SCNS_KEY_S2,
    SCNS_KEY_S3,
    SCNS_KEY_S4,
};

static const gpio_pin_enum ptx[SCNS_BSP_KEYBOARD_GPIO_KEY_MAX]={
    D0,D1,D2,D3
};

ScnsKeyPress scnsBspKeyboardGpioGet(uint8 keyN)
{
    return ((gpio_get_level(ptx[keyN])==0)?SCNS_KEY_PRESS_DOWN:SCNS_KEY_PRESS_UP);
}

ScnsStatus scnsBspKeyboardGpioInit(void)
{
    for(uint8 keyN=0;keyN<SCNS_BSP_KEYBOARD_GPIO_KEY_MAX;++keyN)
        gpio_init(ptx[keyN],GPI,0,GPI_PULL_UP);
    return SCNS_STATUS_OK;
}
ScnsStatus scnsBspKeyboardGpioPostInit(void)
{
    return SCNS_STATUS_OK;
}
#endif
